/*
 * Quote.h
 *
 *  Created on: 2020年12月8日
 *      Author: san
 */

#ifndef QUOTE_H_
#define QUOTE_H_

#include <string>
#include <iostream>

class Quote {
public:
	Quote() {std::cout << "Quote()" << std::endl;};
	Quote(const std::string &book, double sales_price):
		bookNo(book), price(sales_price) { std::cout << "Quote(const std::string &book, double sales_price)" << std::endl;}
	Quote(const Quote &q):bookNo(q.bookNo), price(q.price) {  std::cout << "Quote(const Quote &q)" << std::endl; }
	virtual ~Quote() = default;  // 动态绑定

	std::string isbn() const { return bookNo; }
	virtual double net_price(std::size_t n) const { return n * price; }
	virtual void debug() const { std::cout << "bookNo = " << bookNo << " price = " << price << std::endl; };

	// 返回一个动态对象的拷贝
	// 适用动态绑定机制，必须适用虚函数
	virtual Quote *clone() const & { return new Quote(*this); }
	virtual Quote *clone() && { return new Quote(std::move(*this)); }

private:
	std::string bookNo;
protected:
	double price = 0.0;
};

#endif /* QUOTE_H_ */
